package com.example.project.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.project.entity.ProjUser;
import com.example.project.mapper.ProjUserMapper;
import com.example.project.service.ProjUserService;
import com.example.project.vo.model.PageDto;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.PageHelper;

import javax.annotation.Resource;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.List;

/**
 * (ProjUser)表服务实现类
 */
@Service("projUserService")
public class ProjUserServiceImpl extends ServiceImpl<ProjUserMapper, ProjUser>
        implements ProjUserService {
    @Resource
    private ProjUserMapper projUserMapper;

    @Override
    public ProjUser queryById(Long id) {
        return this.getBaseMapper().selectById(id);
    }

    @Override
    public PageInfo<ProjUser> queryAll(PageDto pageDto) {
        PageHelper.startPage(pageDto.getPage(), pageDto.getSize());
        List<ProjUser> list = this.getBaseMapper().selectList(pageDto.toQueryWrapper());
        return new PageInfo<>(list);
    }

    @Override
    public ProjUser insert(ProjUser projUser) {
        this.getBaseMapper().insert(projUser);
        return projUser;
    }

    @Override
    public ProjUser update(ProjUser projUser) {
        this.getBaseMapper().updateById(projUser);
        return this.queryById(projUser.getId());
    }

    @Override
    public List<ProjUser> querryList() {
        return this.getBaseMapper().selectList(null);
    }

    @Override
    public boolean deleteById(Long id) {
        return this.getBaseMapper().deleteById(id) > 0;
    }
}
